home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / wstring.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  2.9 KB  |  111 lines

  1. // wstring.h - support for delphi widestrings in c++
  2. //                (WideString)
  3. // $Revision:   1.5.2.1  $
  4. // Copyright (c) 1997, 1998 Borland International
  5.  
  6. #ifndef WSTRING_H
  7. #define WSTRING_H
  8.  
  9. #if !defined(SYSDEFS_H)
  10. #include <sysdefs.h>
  11. #endif
  12.  
  13. namespace System
  14. {
  15.   class DELPHIRETURN AnsiString;
  16.   
  17.   // NOTE: WideString uses BSTRs as its underlying implementation (i.e. SysAlloc/FreeString etc.)
  18.   //
  19.   class DELPHIRETURN WideString
  20.   {
  21.     friend WideString __fastcall PACKAGE operator +(const wchar_t*, const WideString& rhs); //!! not implemented?
  22.   public:
  23.     // Constructors
  24.     //
  25.     __fastcall WideString(): Data(0) {}
  26.     __fastcall WideString(const char* src);
  27.     __fastcall WideString(const WideString& src);
  28.     __fastcall WideString(const AnsiString& src);
  29.     __fastcall WideString(const wchar_t* src, int len);
  30.     __fastcall WideString(const wchar_t* src);
  31.     __fastcall WideString(const wchar_t  src);
  32.  
  33.     // Destructor
  34.     //
  35.     __fastcall ~WideString();
  36.  
  37.     // Assignments
  38.     //
  39.     WideString& __fastcall operator =(const WideString& rhs);
  40.     WideString& __fastcall operator =(BSTR              rhs);
  41.     WideString& __fastcall operator +=(const WideString& rhs);
  42.  
  43.     // Comparisons
  44.     //
  45.     bool __fastcall operator ==(const WideString& rhs) const;
  46.     bool __fastcall operator !=(const WideString& rhs) const;
  47.     bool __fastcall operator < (const WideString& rhs) const;
  48.     bool __fastcall operator > (const WideString& rhs) const;
  49.     bool __fastcall operator <=(const WideString& rhs) const;
  50.     bool __fastcall operator >=(const WideString& rhs) const;
  51.  
  52.     // Index
  53.     //
  54.     wchar_t& __fastcall operator [](const int idx) { return Data[idx-1]; }
  55.  
  56.     // Concatenation
  57.     //
  58.     WideString __fastcall operator +(const WideString& rhs) const;
  59.  
  60.     // Access Data
  61.     //
  62.     BSTR __fastcall c_bstr() const { return Data; }
  63.     operator BSTR() const          { return Data; }
  64.  
  65.     // Access internal data (Be careful when using!!)
  66.     //
  67.     BSTR* __fastcall operator& ()
  68.     {
  69.       return &Data;
  70.     }
  71.  
  72.     // Attach/Detach from BSTR, Empty Object
  73.     //
  74.     void __fastcall Attach(BSTR src);
  75.     BSTR __fastcall Detach();
  76.     void __fastcall Empty();
  77.     
  78.     // Retrieve copy of data
  79.     //
  80.     static wchar_t* __fastcall Copy(wchar_t* src);
  81.  
  82.     wchar_t* __fastcall Copy() const
  83.     {
  84.       return Copy(Data);
  85.     }
  86.  
  87.     // Query attributes of object
  88.     //
  89.     int  __fastcall Length() const;
  90.     bool __fastcall IsEmpty() const;
  91.  
  92.     // Modify string
  93.     //
  94.     void __fastcall Insert(const WideString& str, int index);
  95.     void __fastcall Delete(int index, int count);
  96.     void __fastcall SetLength(int newLength);
  97.  
  98.     int  __fastcall Pos(const WideString& subStr) const;
  99.     WideString __fastcall SubString(int index, int count) const;
  100.  
  101.   private:
  102.     wchar_t *Data;
  103.   };
  104. }
  105. using namespace System;
  106. #endif
  107.  
  108.  
  109.  
  110.   
  111.